package com.xiaozhengkeji.servlet.api.email;

import com.xiaozhengkeji.servlet.email.Email;

import javax.mail.MessagingException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

@WebServlet("/api/email/EmailApi")
public class EmailApi extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setCharacterEncoding("UTF-8");
        PrintWriter out = response.getWriter();
        Map<String, String[]> dataMap = request.getParameterMap();
        try {
            Email.giveUserEmail(dataMap.get("useremail")[0], dataMap.get("tag")[0], dataMap.get("txt")[0]);
        } catch (MessagingException e) {
            e.printStackTrace();
        }
    }
}
